import axios from "../axios";
import apiList from "./api-list";
import type { PageShippingDTO, QueryShippingVO, ShippingDetailDTO, ShippingVO } from "./types";

class ShippingController {
  getOrderNumber() {
    return axios.get<string>(apiList.getOrderNumber, {});
  }
  create(data: ShippingVO) {
    return axios.post<string>(apiList.create, data);
  }
  update(data: ShippingVO) {
    return axios.post(apiList.update, data)
  }
  delete(orderId: string) {
    return axios.get(apiList.delete, { orderId });
  }
  getDetail(orderId: string) {
    return axios.get<ShippingDetailDTO>(apiList.detail, { orderId });
  }
  page(data: QueryShippingVO) {
    return axios.post<PageShippingDTO[]>(apiList.page, data);
  }
  getShippingDate(sn: string) {
    return axios.get<string>(apiList.getShippingDate, { productSn: sn })
  }
  importData(fileId: string) {
    return axios.get(apiList.importData, { fileId });
  }
  export(query: QueryShippingVO, selectedIds: string[]) {
    return axios.post<string>(apiList.export, { query, selectedIds })
  }
  getRecentlyContactor(purchaseCompanyCode: string) {
    return axios.get<{ contactor: string, telephone: string, address: string }>(apiList.getRecentlyContactor, { purchaseCompanyCode })
  }
}
export default ShippingController
